package com.mlz.mlzmall.ui.activity.frag.main;


import android.app.Fragment;
import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Toast;

import com.mlz.mlzmall.R;
import com.mlz.mlzmall.custom.ArticleWebView;
import com.mlz.mlzmall.ui.dialog.ReuestDialog;

/**
 * Created by Administrator on 2016/5/20.
 */
public class GoodDetailsFragment extends Fragment {
    private ArticleWebView webView;
    private View view1;
    private String url;
    private Handler myHandler = new Handler();
    public static GoodDetailsFragment newInstance(String url)
    {
        GoodDetailsFragment goodDetailsFragment = new GoodDetailsFragment();
        goodDetailsFragment.url = url;
        return goodDetailsFragment;

    }
    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View rootView = inflater.inflate(R.layout.fragment_product_details, container, false);
        webView = (ArticleWebView) rootView.findViewById(R.id.wv_webview_introduce);
        view1 = rootView.findViewById(R.id.view_blank);
        webView.getSettings().setJavaScriptEnabled(true);//webview适配器
        // webView.loadUrl("http://test.m.mlzmall.com/Home/Product?desc=7157");

        webView.setWebViewClient(new WebViewClient(){
            @Override
            public void onPageFinished(final WebView view, String url) {

            }
        });
        webView.setOnLoadFinishListener(new ArticleWebView.OnLoadFinishListener() {
            @Override
            public void onLoadFinish() {
                myHandler.postDelayed(runnable,1000);
            }
        });
        webView.loadUrl(url);
        return rootView;
    }
    Runnable runnable = new Runnable() {

        @Override
        public void run() {
            view1.setVisibility(View.GONE);
        }
    };
}
